package com.ruoyi.project.wechatprogram.notice.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.wechatprogram.notice.mapper.WxNoticeMapper;
import com.ruoyi.project.wechatprogram.notice.domain.WxNotice;
import com.ruoyi.project.wechatprogram.notice.service.IWxNoticeService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 公告Service业务层处理
 * 
 * @author sxchen
 * @date 2020-05-21
 */
@Service
public class WxNoticeServiceImpl implements IWxNoticeService 
{
    @Autowired
    private WxNoticeMapper wxNoticeMapper;

    /**
     * 查询公告
     * 
     * @param id 公告ID
     * @return 公告
     */
    @Override
    public WxNotice selectWxNoticeById(Integer id)
    {
        return wxNoticeMapper.selectWxNoticeById(id);
    }

    /**
     * 查询公告列表
     * 
     * @param wxNotice 公告
     * @return 公告
     */
    @Override
    public List<WxNotice> selectWxNoticeList(WxNotice wxNotice)
    {
        return wxNoticeMapper.selectWxNoticeList(wxNotice);
    }

    /**
     * 查询公告列表-小程序
     *
     * @param wxNotice 公告
     * @return 公告
     */
    @Override
    public List<WxNotice> selectWxNoticeListNew(WxNotice wxNotice)
    {
        return wxNoticeMapper.selectWxNoticeListNew(wxNotice);
    }

    /**
     * 新增公告
     * 
     * @param wxNotice 公告
     * @return 结果
     */
    @Override
    public int insertWxNotice(WxNotice wxNotice)
    {
        wxNotice.setCreateBy(ShiroUtils.getLoginName());
        wxNotice.setCreateTime(DateUtils.getNowDate());
        wxNotice.setUpdateTime(DateUtils.getNowDate());
        return wxNoticeMapper.insertWxNotice(wxNotice);
    }

    /**
     * 修改公告
     * 
     * @param wxNotice 公告
     * @return 结果
     */
    @Override
    public int updateWxNotice(WxNotice wxNotice)
    {
        wxNotice.setUpdateBy(ShiroUtils.getLoginName());
        wxNotice.setUpdateTime(DateUtils.getNowDate());
        return wxNoticeMapper.updateWxNotice(wxNotice);
    }

    /**
     * 删除公告对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWxNoticeByIds(String ids)
    {
        return wxNoticeMapper.deleteWxNoticeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除公告信息
     * 
     * @param id 公告ID
     * @return 结果
     */
    @Override
    public int deleteWxNoticeById(Integer id)
    {
        return wxNoticeMapper.deleteWxNoticeById(id);
    }
}
